#import "Action.h"

Action::Action()
{
	m_FrameNum = 0;
   // m_myFrame = NULL;
	//frameIndex = 0;
	time = 0;
	bFirst = true;
	bFlash = false;
	frameTime = 0;
	m_bActionFinish = false;
}

Action::~Action()
{
	while (m_myFrame.empty() == false){
		SAFE_DELETE(m_myFrame.back());
		m_myFrame.pop_back();
	}
}

Action::Action(const Action& rA)
{
	m_FrameNum = 0;
    //m_myFrame = NULL;
	//frameIndex = 0;
	time = 0;
	bFirst = true;
	bFlash = false;	
	
    m_FrameNum=rA.m_FrameNum;
	//m_myFrame = new Frame[m_FrameNum];
	for(int i=0;i<m_FrameNum;i++){
		m_myFrame.push_back(new Frame(*(rA.m_myFrame[i])));
     }
}

int Action::drawAction(int frameIndex, int x, int y, int type, int frameID, int off,int changeTime,int m_RoleType,CCTexture* img) 
{
	
}

void Action::resetAction(){
	//frameIndex = 0;
	bFirst = true;
}

void Action::loadFrame(FILE* fp)
{
	fread( &m_FrameNum, sizeof(byte), 1, fp);
	//JavaBitReverse(&m_FrameNum, sizeof(int), 1);
	
	//m_myFrame = new Frame[m_FrameNum];
	for(int i=0;i<m_FrameNum;i++){
		m_myFrame.push_back(new Frame());
		//m_myFrame[i] = new Frame();
		m_myFrame.back()->loadFrame(fp);
	}	
}

vector<Frame*> & Action::GetActionFrame()
{
	return m_myFrame;
}
